package com.zgw.fireline.pharmacy;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class TestDlg extends Dialog {

	protected Object result;
	protected Shell shell;
	private Text text;

	/**
	 * Create the dialog.
	 * 
	 * @param parent
	 * @param style
	 */
	public TestDlg(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * 
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
		shell.setSize(450, 300);
		shell.setText(getText());

		Button btnNewButton = new Button(shell, SWT.NONE);
		btnNewButton.setBounds(58, 55, 72, 22);
		btnNewButton.setText("New Button");

		DesignComp composite = new DesignComp(shell, SWT.BORDER);
		composite.setBounds(58, 161, 135, 83);

		Label lblNewLabel = new Label(composite, SWT.NONE);
		lblNewLabel.setBounds(20, 24, 54, 12);
		lblNewLabel.setText("New Label");

		Composite composite_1 = new Composite(shell, SWT.NONE);
		composite_1.setBounds(191, 13, 190, 135);

		Composite composite_2 = new Composite(composite_1, SWT.NONE);
		composite_2.setBounds(10, 10, 85, 73);

		text = new Text(composite_2, SWT.BORDER);
		text.setBounds(10, 34, 70, 18);
		
	}
}
